package com.zjht.gmcc.servlet.sys;

import java.io.PrintWriter;
import java.sql.PreparedStatement;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.zjht.gmcc.bean.BaseServlet;
import com.zjht.gmcc.bean.util.InitParam;
import com.zjht.gmcc.bean.util.MyJDBC;

/**
 * 撤销入柜商服务厅与移动自有厅关联关系
 * @author 朱家进
 */
public class CancelRGSRelation extends BaseServlet {

	private static final long serialVersionUID = -1419654698615505582L;

	public boolean process(HttpServletRequest request, HttpServletResponse response, HttpSession session, PrintWriter out, MyJDBC myJDBC, String menu)
			throws Exception {

		String s_orgatype = request.getParameter("orgaType");
		String s_orgacode = request.getParameter("orgacode");

		int i_flag = 0;
		PreparedStatement ps = null;

		String channelType = "02";
		String gmccHall = request.getParameter("gmccHall");

		if (s_orgatype == null || s_orgatype.length() == 0) {
			alert(out, "无法更新组织信息，请与管理员联系。");
			return false;
		}

		String s_sql = "";
		s_sql = "DELETE mobiletorgs WHERE rgscode = ? AND mobilecode = ? ";
		ps = myJDBC.prepareStatement(s_sql);
		ps.setString(1, s_orgacode);
		ps.setString(2, gmccHall);

		i_flag = ps.executeUpdate();
		ps.close();

		String act = "撤销与自有厅对应关系";
		if (i_flag > 0) {
			InitParam.initOrgaInfo();
			alert(out, act + "成功", "/sys/orga/orga.jsp?orgacode=" + s_orgacode + "&orgaType=" + s_orgatype + "&channelType=" + channelType);
		} else {
			errAlert(request, out, menu, act + "失败");
		}
		return i_flag > 0;
	}
}
